
uniform vec4 animationData[10];
uniform vec3 jointList[10];

uniform sampler2D meshTexture;

varying vec3 eyeNormal;
varying vec3 eyePosition;

varying vec3 rootTranslationDebug;
varying vec4 vClosestJointIdList;
varying float vClosestJointId;

varying vec3 vJointColor;

vec3 getClosestJointColor() {
	vec3 colors[10];
	
	for(int i = 0; i < 10; i++) {
		colors[i] = vec3(0.0,0.0,255.0);
	}
	
	colors[26] = vec3(0.0,255.0,0.0);
	
	return colors[int(vClosestJointId)];
	
}


void main (void)
{
   
    vec3 baseMapColor = vec3(0.0, 255.0, 0.0);
    
	baseMapColor = texture2D(meshTexture, gl_TexCoord[0].st).rgb;
	/*
	if(animationData[0] == vec4(0.0265202, 16.2134, -25.4911, 0.0)) {
		baseMapColor = vec3(1.0, 0.0, 0.0);
	}
	*/
	
	
    vec3 normal = normalize(eyeNormal); 
    vec3 light = normalize( vec3(0,10,-10));
    vec3 eye = normalize( eyePosition);
    vec3 r = reflect( eye, normal);
    const vec3 red = vec3( 0.5, 0.5, 0.5);
    const vec3 white = vec3( 1, 1, 1);

    // Compute a simple phong illumination with a directional light
    float ndotl = dot( normal, light);    
    ndotl = min( max( ndotl, 0.0) + 0.2, 1.0);
    float spec = pow( max( 0.0, dot( r, light)), 32.0);
    
    vec3 color = 2.0*clamp( ndotl*red + spec*white, 0.0, 1.0); 

    // Output the fragment color   
    gl_FragColor = vec4( baseMapColor*color, 1.0);  
	// gl_FragColor = vec4(vJointColor, 1.0);
   //gl_FragColor = vec4( baseMapColor, 1.0);  
}